//
//  UIView+Shadow.swift
//  AirlineReservation
//
//  Created by Kevin on 2020/1/21.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

extension UIView {

    func addShadow(with color: UIColor) {
        layer.shadowColor = color.cgColor
        layer.shadowRadius = 8
        layer.shadowOpacity = 0.7
        layer.shadowOffset = CGSize(width: 0, height: 5)
    }

    func removeShadow() {
        layer.shadowOpacity = 0
    }
    
    // 更新视图
    @objc func updateLayout() -> Void {
        for item in subviews {
            for i in item.subviews {
                i.removeFromSuperview()
            }
            item.removeFromSuperview()
        }
        setNeedsLayout()
    }
}
